<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>sendAJAX</title>
	<style type="text/css">
	* {
		padding: 0;
		margin: 0;
	}
</style>
</head>
<body>
	<div class="container">
		<h1>sendAJAX</h1>
	</div>
	<script src="https://cdn.staticfile.org/jquery/3.2.0/jquery.js"></script>
	<script src="js/sendAJAX.js"></script>
	<script type="text/javascript">
		function sleep(ms) {
			var start = Date.now()
			while(Date.now() - start <= ms ) ; 
		}


		let p1 = sendAJAX('http://localhost/ajax/ajax3.php?type=p1&t=0'); 

        // let p2 = Promise.resolve('Success');
        let p2 = sendAJAX('http://localhost/ajax/ajax3.php?type=p2');
        // let p3 = sendAJAX('https://api.apiopen.top/getJoke')
        let p3 = sendAJAX('http://localhost/ajax/ajax3.php?type=p3&t=1  ')
        
        console.time('aa')
        const result = Promise.all([p2, p1, p3]);

        console.log(result);
      
        setTimeout(() => {
        	console.log("setTimeout", result)
        })


        result.then((value, arg2, arg3) => {
        	console.log('value', value) ;
        	console.log('result.then', result)
        	console.timeEnd('aa')
        }, (error, arg2, arg3) => {
        	console.log('error => ', error, arg2, arg3) ;
        })


        Promise.resolve().then(() => {
	        console.log('then', result);
        })
    </script>
</body>
</html>